import { Controller, Get, Param, Query, UseFilters } from '@nestjs/common';
import { UserService } from './user.service';
import { MyExceptionFilter } from 'src/my-exception.filter';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  // http://localhost:3000/user/list
  @Get('list')
  getUserList() {
    return this.userService.getList();
  }

  // /find?age=1&name=dd
  @Get('find')
  @UseFilters(MyExceptionFilter)
  query(@Query('name') name: string, @Query('age') age: number) {
    return this.userService.query(name, age);
  }

  // /user/1
  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.userService.findOne(+id);
  }
}
